<html>
<head><meta charset="utf-8"><title>A SimdVector trait · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html">A SimdVector trait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="237394842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237394842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237394842">(May 04 2021 at 20:45)</a>:</h4>
<p>In <a href="https://github.com/rust-lang/rust/issues/103">#103</a> I raised a mild question about using a (sealed) trait for the implementation. While I think having all the fairly <em>arithmetic</em> methods be "core" to the type makes the most sense, I have begun to think it might make sense to define something like a "SimdVector" trait that notionally implements the methods that "view" a vector type <em>as</em> an abstract vector, and that this may help futureproof us against situations where our API might have name collision with other things (this comes up with the "rotate/shift" stuff a lot) by allowing qualified path syntax as an escape valve.</p>



<a name="237395236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237395236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237395236">(May 04 2021 at 20:48)</a>:</h4>
<p>I personally think this belongs in a separate crate, similar to num-traits</p>



<a name="237395394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237395394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237395394">(May 04 2021 at 20:49)</a>:</h4>
<p>Providing a "general purpose" trait is particularly dangerous since it's so difficult to keep backward compatible</p>



<a name="237396617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237396617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237396617">(May 04 2021 at 20:58)</a>:</h4>
<p>We should at least have a general purpose trait for <code>LanesAtMost32</code> that only depends on the lane count, not the underlying vector type, since this makes generic code waay easier to write.</p>



<a name="237397078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237397078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237397078">(May 04 2021 at 21:00)</a>:</h4>
<p>You mean like <code>[(); LANES]: Trait</code></p>



<a name="237397100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237397100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237397100">(May 04 2021 at 21:01)</a>:</h4>
<p>You're probably right</p>



<a name="237397458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237397458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237397458">(May 04 2021 at 21:02)</a>:</h4>
<p>Should also probably make that trait more generically names since I think it will probably be stabilized eventually</p>



<a name="237397544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237397544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237397544">(May 04 2021 at 21:02)</a>:</h4>
<p>Even if it eventually is implemented for all lanes from 0 to 65536 or whatever</p>



<a name="237403842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237403842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237403842">(May 04 2021 at 21:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait/near/237395394">said</a>:</p>
<blockquote>
<p>Providing a "general purpose" trait is particularly dangerous since it's so difficult to keep backward compatible</p>
</blockquote>
<p>I don't think it should be fully general, I think it should have a point, and the point is more akin to the Iterator trait, in a sense?</p>



<a name="237404329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237404329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237404329">(May 04 2021 at 21:35)</a>:</h4>
<p>idea for replacement for <code>LanesAtMost32</code>:<br>
<a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ac1a184aa94782e3b4abf6a858208e1d">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ac1a184aa94782e3b4abf6a858208e1d</a></p>



<a name="237405190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237405190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237405190">(May 04 2021 at 21:42)</a>:</h4>
<p>I suppose I don't see any reason to use a trait for that</p>



<a name="237405254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237405254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237405254">(May 04 2021 at 21:43)</a>:</h4>
<p>Integers don't have traits that abstract over their methods</p>



<a name="237406811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237406811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237406811">(May 04 2021 at 21:56)</a>:</h4>
<p>Reading and writing is abstracted over multiple containers tho'. My contention is that here, we have something that more resembles a general abstraction, else why have <code>Select</code> as a trait at all?</p>



<a name="237407912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237407912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237407912">(May 04 2021 at 22:04)</a>:</h4>
<p>Well Select specifically encodes that the type matches the mask</p>



<a name="237408022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237408022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237408022">(May 04 2021 at 22:05)</a>:</h4>
<p>I think there's an argument for shuffles to potentially have that as well but not for the sake of name collision</p>



<a name="237408325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237408325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237408325">(May 04 2021 at 22:08)</a>:</h4>
<p>Well, I think the name collision "thing" is basically a nice perk rather than a must-have.</p>



<a name="237408405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237408405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237408405">(May 04 2021 at 22:08)</a>:</h4>
<p>So the reason to use a trait here was so select didn't have a different function for each vector type</p>



<a name="237408434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237408434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237408434">(May 04 2021 at 22:09)</a>:</h4>
<p>I'm not sure if anything else will have that?</p>



<a name="237408466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237408466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237408466">(May 04 2021 at 22:09)</a>:</h4>
<p>Except shuffles with the const type</p>



<a name="237410881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237410881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237410881">(May 04 2021 at 22:33)</a>:</h4>
<p>Reminder: The fact that integers don't have a trait is <em>very bad</em> and <em>everyone hates it</em>.</p>



<a name="237410936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237410936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237410936">(May 04 2021 at 22:33)</a>:</h4>
<p>Also T-libs members have actually, recently, solicited an impl PR for it.</p>



<a name="237410957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237410957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237410957">(May 04 2021 at 22:34)</a>:</h4>
<p>That exact thing.</p>



<a name="237411269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237411269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237411269">(May 04 2021 at 22:36)</a>:</h4>
<p>I think it would make sense to wait for the primitive traits and go from there</p>



<a name="237411315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237411315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237411315">(May 04 2021 at 22:37)</a>:</h4>
<p>And perhaps take part in that conversation</p>



<a name="237411377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237411377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237411377">(May 04 2021 at 22:37)</a>:</h4>
<p>Mmm, I don't think this is the same thing though. This is abstracting over what we <strong>don't</strong> have in common with numbers.</p>



<a name="237411481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237411481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237411481">(May 04 2021 at 22:38)</a>:</h4>
<p>Right, but I think it would make sense to see what the implementation looks like</p>



<a name="237411530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237411530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237411530">(May 04 2021 at 22:38)</a>:</h4>
<p>And implement the simd traits informed by that</p>



<a name="237411725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237411725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237411725">(May 04 2021 at 22:40)</a>:</h4>
<p>Are you suggesting that we shouldn't have type member fns at all for these things and should only use traits? Because I don't think that's a good idea. And if the traits are purely on top of those then I don't see any harm in waiting</p>



<a name="237412444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412444">(May 04 2021 at 22:47)</a>:</h4>
<p>Yeah, actually, that's what I think, because here I want a lucid API that has compartmentalization of information, and while I think having all the mathematical operations be immediate is one thing and is fine, I think a single abstract trait that implements the behavior of "doing meta-manipulations over lanes" is superior for those particular functions because then people can look at that one trait for reference on what they can do with our relevant types, just like they actually read the documentation for Iterator and can write abstractions over vector manipulations.</p>



<a name="237412566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412566">(May 04 2021 at 22:48)</a>:</h4>
<p>Okay so I think I support that for shuffles</p>



<a name="237412604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412604">(May 04 2021 at 22:49)</a>:</h4>
<p>(and I think I suggested it in one of these threads somewhere?)</p>



<a name="237412611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412611">(May 04 2021 at 22:49)</a>:</h4>
<p>Possibly.</p>



<a name="237412632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412632">(May 04 2021 at 22:49)</a>:</h4>
<p>Though I don't believe it should be a trait that you interact with, much like you don't interact with Select</p>



<a name="237412721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412721">(May 04 2021 at 22:50)</a>:</h4>
<p>Maybe I'm wrong, maybe it should because of reverse etc</p>



<a name="237412724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412724">(May 04 2021 at 22:50)</a>:</h4>
<p>I'm not sure that will scale to actual usage.</p>



<a name="237412769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412769">(May 04 2021 at 22:50)</a>:</h4>
<p>But I think <code>shuffle</code> itself should be a free function, personally</p>



<a name="237412840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412840">(May 04 2021 at 22:51)</a>:</h4>
<p>I'm not sure it makes much sense being a member fn</p>



<a name="237412948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412948">(May 04 2021 at 22:52)</a>:</h4>
<p>The problem with traits is that you need to import them to use them</p>



<a name="237412953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412953">(May 04 2021 at 22:52)</a>:</h4>
<p>Hm, that isn't part of the patterns in my brain that I intuit, but I'm not sure it's bad.</p>



<a name="237412983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412983">(May 04 2021 at 22:53)</a>:</h4>
<p>Well, you need to import free fn as well.</p>



<a name="237412985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412985">(May 04 2021 at 22:53)</a>:</h4>
<p>Not the biggest problem but may hurt discoverability</p>



<a name="237412995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237412995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237412995">(May 04 2021 at 22:53)</a>:</h4>
<p>Agreed</p>



<a name="237413032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237413032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237413032">(May 04 2021 at 22:53)</a>:</h4>
<p>I meant a free function as part of the trait thing, like iterator sum</p>



<a name="237413060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237413060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237413060">(May 04 2021 at 22:54)</a>:</h4>
<p>Ah.<br>
Well, discoverability is basically why I want all the """""""""weird""""""""" APIs to be in a single trait.</p>



<a name="237413110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237413110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237413110">(May 04 2021 at 22:54)</a>:</h4>
<p>airquoting heavily here</p>



<a name="237413125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237413125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237413125">(May 04 2021 at 22:54)</a>:</h4>
<p>might be able to fit a few more quotation marks in, let's see</p>



<a name="237413136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237413136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237413136">(May 04 2021 at 22:54)</a>:</h4>
<p>yeah that's about right.</p>



<a name="237413148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237413148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237413148">(May 04 2021 at 22:54)</a>:</h4>
<p>Lol</p>



<a name="237415458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237415458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237415458">(May 04 2021 at 23:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait/near/237410936">said</a>:</p>
<blockquote>
<p>Also T-libs members have actually, recently, solicited an impl PR for it.</p>
</blockquote>
<p>Yes please. I'd <em>love</em> to have a trait (or, more likely, a family of traits) that includes things like ::BITS.</p>



<a name="237417335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237417335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237417335">(May 04 2021 at 23:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait/near/237405190">said</a>:</p>
<blockquote>
<p>I suppose I don't see any reason to use a trait for that</p>
</blockquote>
<p>you'd abstract over the lane count so you can implement element-wise operations. example:<br>
<a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=5f753543bd617494aeefdc0f9ff39c52">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=5f753543bd617494aeefdc0f9ff39c52</a></p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">example_generic_fn</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">SimdLanes</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span>: <span class="nc">SimdU32</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="nc">SimdF64</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">SimdF64</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span><span class="p">.</span><span class="n">into</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">b</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="237417435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237417435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237417435">(May 04 2021 at 23:38)</a>:</h4>
<p>I am very much opposed to anything involving supertraits since they cannot be changed</p>



<a name="237429046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237429046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237429046">(May 05 2021 at 01:49)</a>:</h4>
<p>yeah while I mentioned that I think a trait is a good idea I don't think supertraits are required here.</p>



<a name="237472257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237472257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237472257">(May 05 2021 at 10:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait/near/237417435">said</a>:</p>
<blockquote>
<p>I am very much opposed to anything involving supertraits since they cannot be changed</p>
</blockquote>
<p>are you referring to <code>SimdLanes</code> in my example code, or something else?</p>



<a name="237490988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237490988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237490988">(May 05 2021 at 13:03)</a>:</h4>
<p>Traits having to be imported just means we need to have our bonus prelude include all the traits.</p>



<a name="237497246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237497246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237497246">(May 05 2021 at 13:46)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> yes</p>



<a name="237552147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237552147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237552147">(May 05 2021 at 19:27)</a>:</h4>
<p>hmm, well, I don't see how having <code>Sealed</code> be a supertrait of <code>SimdLanes</code> can cause any problems, it's not as if <code>Sealed</code> has any publicly accessible items...they are all <code>#[doc(hidden)]</code> and would be unstable implementation details.</p>
<p>Also, if your using vectors with known lengths, you don't have to import any traits at all. <code>SimdLanes</code> has just one public field, <code>LANES</code>, and that's just cause it's handy, not because it's necessary.</p>



<a name="237552212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237552212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237552212">(May 05 2021 at 19:27)</a>:</h4>
<p>I was referring to SimdLanes being a supertrait of Into and Mul like in your example</p>



<a name="237555085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/A%20SimdVector%20trait/near/237555085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait.html#237555085">(May 05 2021 at 19:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/A.20SimdVector.20trait/near/237552212">said</a>:</p>
<blockquote>
<p>I was referring to SimdLanes being a supertrait of Into and Mul like in your example</p>
</blockquote>
<p>hmm, well I don't see how <code>SimdLanes</code> is a supertrait of <code>Into</code> or <code>Mul</code>, it's just a bound on the generic argument, just like how we need to write <code>SimdU32&lt;LANES&gt;: LanesAtMost32</code> now. If a user's code isn't being generic over the lane count, then it never needs to mention/import <code>SimdLanes</code>:</p>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d0243e557ef5e0055c92fe0fc20c02db">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d0243e557ef5e0055c92fe0fc20c02db</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>